Linux_Linux系统中的内存清理和释放命令归纳小记,# 清理步骤# 清理前内存使用情
# 清理步骤
# 清理前内存使用情况
复制代码
代码如下:free -m
# 开始清理
复制代码
代码如下:echo 1 > /proc/sys/vm/drop_caches
# 清理后内存使用情况
复制代码
代码如下:free -m
完成!
# 查看内存条数命令:
复制代码
代码如下:dmidecode | grep -A16 "Memory Device$"
To free pagecache:
echo 1 > /proc/sys/vm/drop_caches
To free dentries and inodes:
echo 2 > /proc/sys/vm/drop_caches
To free pagecache, dentries and inodes:
echo 3 > /proc/sys/vm/drop_caches
sync
# 释放前最好sync一下,防止丢数据。因为LINUX的内核机制,一般情况下不需要特意去释放已经使用的cache。这些cache起来的内容可以增加文件以及的读写速度。
# 先说下free命令怎么看内存
复制代码
代码如下:$free
total used free shared buffers cached
Mem: 1535052 918928 616124 0 2512 82964
-/+ buffers/cache: 833452 701600
Swap: 0 0 0
# 第一行用全局角度描述系统使用的内存状况:
total——总物理内存
used——已使用内存,一般情况这个值会比较大,因为这个值包括了cache+应用程序使用的内存
free——完全未被使用的内存
shared——应用程序共享内存
buffers——缓存,主要用于目录方面,inode值等(ls大目录可看到这个值增加)
cached——缓存,用于已打开的文件
total = used + free
used = buffers+cached (maybe add shared also)
第二行描述应用程序的内存使用:
前个值表示-buffers/cache——应用程序使用的内存大小,used减去缓存值
后个值表示+buffers/cache——所有可供应用程序使用的内存大小,free加上缓存值
-buffers/cache=used-buffers-cached
+buffers/cache=free+buffers+cached
第三行表示swap的使用:
used——已使用
free——未使用
手动执行sync命令(描述:sync 命令运行 sync 子例程。如果必须停止系统,则运行 sync 命令以确保文件系统的完整性。sync 命令将所有未写的系统缓冲区写到磁盘中,包含已修改的 i-node、已延迟的块 I/O 和读写映射文件)
echo 3 > /proc/sys/vm/drop_caches
cat /proc/sys/vm/drop_caches
3
!将/proc/sys/vm/drop_caches值设为3
# 有关/proc/sys/vm/drop_caches的用法在下面进行了说明
复制代码
代码如下:/proc/sys/vm/drop_caches (since Linux 2.6.16)
Writing to this file causes the kernel to drop clean caches,
dentries and inodes from memory, causing that memory to become
free.
To free pagecache, use echo 1 > /proc/sys/vm/drop_caches; to
free dentries and inodes, use echo 2 > /proc/sys/vm/drop_caches;
to free pagecache, dentries and inodes, use echo 3 >
/proc/sys/vm/drop_caches.
Because this is a non-destructive operation and dirty objects
# 原文链接:<a href="https://levi.cg.am/?p=3224">?p=3224</a>
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/xt/linux/11493.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
并进行了数次优化更改
时间:2021-01-23
-
在Linus发表文章的第二年
时间:2021-01-23
-
当一个文件被加载时
时间:2021-01-21
-
与--delete 呼应的是--exis
时间:2021-01-21
-
$top top-18:50:38up6days
时间:2021-01-21
-
CLI和程序包管理器使开发
时间:2021-01-20
-
但是有时候这个系统上跑
时间:2021-01-20
-
配置好prometheus数据源
时间:2021-01-20
热门文章
-
Anki:让记忆更轻松的开源神器
时间:2020-12-22
-
配置好prometheus数据源
时间:2021-01-20
-
如何在Linux启动时自动启动LXD容器
时间:2020-12-22
-
使用Vi/Vim编辑器:基础篇
时间:2020-12-22
-
linux系统比windows系统声音小怎么办?
时间:2021-01-08
-
使用parallel利用起你的所有CPU资源
时间:2020-12-22
-
Zsync:一个仅下载文件新的部分的传输工
时间:2020-12-22
-
Linux SecureCRT显示乱码解决方案
时间:2021-01-05
-
linux 防御SYN攻击步骤详解
时间:2020-12-23
-
在Linus发表文章的第二年
时间:2021-01-23
